﻿using Abp;
using Abp.AspNetCore.Mvc.Controllers;
using Abp.Auditing;
using Abp.Dependency;
using Abp.Modules;
using HCD.Const;
using HCD.Core.AuditLog;
using HCD.Resources.Localization;

namespace HCD
{
    public class EnterpriseCoreModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.Auditing.IsEnabled =true;
            Configuration.Auditing.IsEnabledForAnonymousUsers = true;
            Configuration.ReplaceService(typeof(IAuditingStore), () =>
            {
                IocManager.Register<IAuditingStore, HCDAuditingStore>(DependencyLifeStyle.Transient);
            });
            // Configuration.Auditing.Selectors.Clear();
            // Configuration.Auditing.Selectors.Add(
            //     new NamedTypeSelector(
            //         "HCD.Controller",
            //         type => typeof (AbpController).IsAssignableFrom(type)
            //     )
            // );
            EntLocalizationConfiguration.Config(Configuration.Localization, EnterpriseConsts.LocalizationSourceName);
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(typeof(EnterpriseCoreModule).Assembly);
        }
    }
}